#!/usr/bin/env python3
import sys
import os
sys.path.append('.')
from config import get_database_config
try:
    import mysql.connector  # type: ignore
except ImportError:
    print("请安装mysql-connector-python: pip install mysql-connector-python")
    sys.exit(1)

try:
    config = get_database_config()
    conn = mysql.connector.connect(**config)
    cursor = conn.cursor()
    
    print("fund_nav_detail表结构:")
    cursor.execute('DESCRIBE fund_nav_detail')
    for row in cursor.fetchall():
        print(row)
    
    print("\n检查是否有数据:")
    cursor.execute('SELECT COUNT(*) FROM fund_nav_detail')
    count = cursor.fetchone()[0]
    print(f"fund_nav_detail表中有 {count} 条记录")
    
    if count > 0:
        print("\n最新的5条记录:")
        cursor.execute('SELECT * FROM fund_nav_detail ORDER BY created_at DESC LIMIT 5')
        for row in cursor.fetchall():
            print(row)
    
    cursor.close()
    conn.close()
    
except Exception as e:
    print(f"错误: {e}")